package com.buba.springcloud.controller;

import com.buba.springcloud.entities.CommonResult;
import com.buba.springcloud.entities.HfFoods;
import com.buba.springcloud.entities.HfFoodtype;
import com.buba.springcloud.service.FoodTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author taodeyu
 * @Date 2022/1/5 下午 8:41
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/backstagesupporter")
public class FoodTypeController {
    @Resource
    private FoodTypeService foodTypeService;

    /**
     * 获取食物类型
     * @return
     */
    @GetMapping("/getFoodType")
    public CommonResult getFoodType(){
        List<HfFoodtype> foodtypes =  foodTypeService.getFoodType();
        if ( foodtypes!= null){
            return new CommonResult(200,"查询成功",foodtypes);
        }
        return new CommonResult(500,"查询失败");
    }

    /**
     * 删除食物类型(逻辑删除)
     * @param id
     * @return
     */
    @DeleteMapping("/deleteFoodTypeById")
    public CommonResult deleteFoodTypeById(Integer id){
        Integer integer = foodTypeService.deleteFoodTypeById(id);
        if (integer ==1 ){
            return new CommonResult(200,"修改成功",foodTypeService.getFoodType());
        }
        return new CommonResult(500,"修改失败");
    }
}
